﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NullStorage.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   The null storage.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Services.Storage
{
    using System.Linq.Expressions;

    /// <summary>
    /// Bull storage implementation.
    /// </summary>
    public sealed class NullStorage : IStorage
    {
        /// <summary>
        /// The dispose.
        /// </summary>
        public void Dispose()
        {
        }

        /// <summary>
        /// Gets the name context for the current storage - this implementation does nothing.
        /// </summary>
        public string Name
        {
            get { return null; }
        }

        /// <summary>
        /// Reads a value from storage using the name of an existing name value pair - this implementation does nothing.
        /// </summary>
        /// <param name="name">
        /// The name of the name value pair.
        /// </param>
        /// <typeparam name="T">
        /// The type of the value of the name value pair.
        /// </typeparam>
        /// <returns>
        /// Returns the value or null.
        /// </returns>
        public T Read<T>(string name)
        {
            return default(T);
        }

        /// <summary>
        /// Reads a value from storage using the name of an existing name value pair - this implementation does nothing.
        /// </summary>
        /// <param name="expression">
        /// Expression which name represents the name of the name value pair.
        /// </param>
        /// <typeparam name="T">
        /// The type of the value of the name value pair.
        /// </typeparam>
        /// <returns>
        /// Returns the value or null.
        /// </returns>
        public T Read<T>(Expression<System.Func<object>> expression)
        {
            return default(T);
        }

        /// <summary>
        /// Writes a value to storage - this implementation does nothing.
        /// </summary>
        /// <param name="name">
        /// The name of the name value pair.
        /// </param>
        /// <param name="value">
        /// The value of the name value pair.
        /// </param>
        /// <typeparam name="T">
        /// The type of the value of the name value pair.
        /// </typeparam>
        /// <returns>
        /// Returns the instance of the storage - fluent interface style.
        /// </returns>
        public IStorage Write<T>(string name, T value)
        {
            return this;
        }

        /// <summary>
        /// Writes a value to storage - this implementation does nothing.
        /// </summary>
        /// <param name="expression">
        /// Expression which name represents the name of the name value pair.
        /// </param>
        /// <param name="value">
        /// The value of the name value pair.
        /// </param>
        /// <typeparam name="T">
        /// The type of the value of the name value pair.
        /// </typeparam>
        /// <returns>
        /// Returns the instance of the storage - fluent interface style.
        /// </returns>
        public IStorage Write<T>(Expression<System.Func<object>> expression, T value)
        {
            return this;
        }

        /// <summary>
        /// Flushes any pending storage requests - this implementation does nothing.
        /// </summary>
        /// <returns>
        /// Returns the instance of the storage - fluent interface style.
        /// </returns>
        public IStorage Flush()
        {
            return this;
        }

        /// <summary>
        /// Clears the storage - this implementation does nothing.
        /// </summary>
        /// <returns>
        /// Returns the instance of the storage - fluent interface style.
        /// </returns>
        public IStorage Clear()
        {
            return this;
        }
    }
}